function one() {
  $(".btn").on("click", function () {
    if (
      $('input[name="username"]').val() == "" ||
      $('input[name="password"]').val() == ""
    ) {
      alert("请输入完整信息");
      return;
    }
    $.ajax({
      type: "post",
      url: "http://localhost:8088/api/login",
      data: {
        username: $('input[name="username"]').val(),
        password: $('input[name="password"]').val(),
      },
      success: function (list) {
        console.log(list);
        if (list.resultCode == 1) {
          let user = {
            headerimg: list.resultInfo.headerimg,
            username: list.resultInfo.nick,
          };
          console.log(user)
          localStorage.setItem("Cart", JSON.stringify(user));
          location.href='./模板引擎2.html'
        }
      },
      error: function (err) {
        alert("错误信息" + err);
      },
    });
  });
}
one();
//焦点验证
$('input[name="username"]').blur(function () {
  if ($('input[name="username"]').val() == "") {
    $('input[name="username"]').next().css({ display: "block" });
  } else {
    $('input[name="username"]').next().css({ display: "none" });
  }
});
$('input[name="password"]').blur(function () {
  if ($('input[name="password"]').val() == "") {
    $('input[name="password"]').next().css({ display: "block" });
  } else {
    $('input[name="password"]').next().css({ display: "none" });
  }
});
